home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1998 August / PC Direct August 1998.iso / S / powerj / Product / hpp.z / WDATANAV.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  7.9 KB  |  289 lines

  1. /*************************************************************************
  2.  *
  3.  * WDataNavigator 
  4.  *
  5.  *   Events:
  6.  *
  7.  *       Click --
  8.  *
  9.  *       DataAvailable --
  10.  *
  11.  *       DataClose --
  12.  *
  13.  *       DataOpen --
  14.  *
  15.  *       DataRequest --
  16.  *
  17.  *************************************************************************/
  18.  
  19. #ifndef _WDATANAV_HPP_INCLUDED
  20. #define _WDATANAV_HPP_INCLUDED
  21.  
  22. #ifndef _WNO_PRAGMA_PUSH
  23. #pragma pack(push,8);
  24. #pragma enum int;
  25. #endif
  26.  
  27. #ifndef _WWINDOW_HPP_INCLUDED
  28. #  include "wwindow.hpp"
  29. #endif
  30. #ifndef _WCONTROL_HPP_INCLUDED
  31. #  include "wcontrol.hpp"
  32. #endif
  33. #ifndef _WDATATRG_HPP_INCLUDED
  34. #  include "wdatatrg.hpp"
  35. #endif
  36. #ifndef _WDATASRC_HPP_INCLUDED
  37. #  include "wdatasrc.hpp"
  38. #endif
  39.  
  40. enum WDNAction {
  41.     WDNActionNone,
  42.     WDNActionMoveFirst,
  43.     WDNActionMoveLast
  44. };
  45.  
  46. enum WDNButton {
  47.     WDNButtonMoveFirst,
  48.     WDNButtonMovePrevious,
  49.     WDNButtonMoveNext,
  50.     WDNButtonMoveLast,
  51.     WDNButtonAdd,
  52.     WDNButtonDelete,
  53.     WDNButtonEdit,
  54.     WDNButtonUpdate,
  55.     WDNButtonCancel,
  56.     WDNButtonRefresh,
  57.     WDNButtonSearch,
  58.  
  59.     WDNButtonLastPlusOne
  60. };
  61.  
  62. struct WDataNavigatorEventData : public WMouseEventData {
  63.     WDNButton whichButton;
  64. };
  65.  
  66. //
  67. // DataNavigator styles
  68. //
  69.  
  70. #define WDNSDefault             ((WStyle)0x50000000L) // WS_VISIBLE|WS_CHILD
  71.  
  72. class WCMCLASS WDataNavigator : public WControl {
  73.     WDeclareSubclass( WDataNavigator, WControl );
  74.  
  75.     public:
  76.     
  77.         /***************************************************************
  78.          * Constructors and Destructors
  79.          ***************************************************************/
  80.  
  81.         WDataNavigator();
  82.     
  83.         ~WDataNavigator();
  84.  
  85.         /***************************************************************
  86.          * Properties
  87.          ***************************************************************/
  88.  
  89.         // BOFAction
  90.         //
  91.         //    Determines what to do when the cursor is moved to the
  92.         //    beginning of the query.
  93.  
  94.         WDNAction GetBOFAction() const;
  95.         WBool     SetBOFAction( WDNAction action );
  96.  
  97.         // DataSource
  98.         //
  99.         //    The data source to track.
  100.  
  101.         WDataSource *GetDataSource() const;
  102.         WBool        SetDataSource( WDataSource *source );
  103.  
  104.         // EOFAction
  105.         //
  106.         //    Determines what to do when the cursor is moved to the
  107.         //    end of the query.
  108.  
  109.         WDNAction GetEOFAction() const;
  110.         WBool     SetEOFAction( WDNAction action );
  111.  
  112.         // KeepFocus
  113.         //
  114.         //    If TRUE, the focus stays on a button when the user
  115.         //    clicks on it, otherwise it returns to where it came
  116.         //    from.
  117.  
  118.         WBool GetKeepFocus() const;
  119.         WBool SetKeepFocus( WBool keep );
  120.  
  121.         // ShowAdd
  122.         //
  123.         //    Show the Add button.
  124.  
  125.         WBool GetShowAdd() const;
  126.         WBool SetShowAdd( WBool show );
  127.  
  128.         // ShowCancel
  129.         //
  130.         //    Show the cancel button.
  131.  
  132.         WBool GetShowCancel() const;
  133.         WBool SetShowCancel( WBool show );
  134.  
  135.         // ShowDelete
  136.         //
  137.         //    Show the delete button.
  138.  
  139.         WBool GetShowDelete() const;
  140.         WBool SetShowDelete( WBool show );
  141.  
  142.         // ShowEdit
  143.         //
  144.         //    Show the edit button.
  145.  
  146.         WBool GetShowEdit() const;
  147.         WBool SetShowEdit( WBool show );
  148.  
  149.         // ShowMoveFirst
  150.         //
  151.         //    Show the movefirst button.
  152.  
  153.         WBool GetShowMoveFirst() const;
  154.         WBool SetShowMoveFirst( WBool show );
  155.  
  156.         // ShowMoveLast
  157.         //
  158.         //    Show the movelast button.
  159.  
  160.         WBool GetShowMoveLast() const;
  161.         WBool SetShowMoveLast( WBool show );
  162.  
  163.         // ShowMoveNext
  164.         //
  165.         //    Show the movenext button.
  166.  
  167.         WBool GetShowMoveNext() const;
  168.         WBool SetShowMoveNext( WBool show );
  169.  
  170.         // ShowMovePrevious
  171.         //
  172.         //   Show the moveprevious button.
  173.  
  174.         WBool GetShowMovePrevious() const;
  175.         WBool SetShowMovePrevious( WBool show );
  176.  
  177.         // ShowRefresh
  178.         //
  179.         //   Show the refresh button.
  180.  
  181.         WBool GetShowRefresh() const;
  182.         WBool SetShowRefresh( WBool show );
  183.  
  184.         // ShowSearch
  185.         //
  186.         //   Show the search button.
  187.  
  188.         WBool GetShowSearch() const;
  189.         WBool SetShowSearch( WBool show );
  190.  
  191.         // ShowTooltips
  192.         //
  193.         //   Show the tooltips.
  194.  
  195.         WBool GetShowTooltips() const;
  196.         WBool SetShowTooltips( WBool show );
  197.  
  198.         // ShowUpdate
  199.         //
  200.         //   Show the update button.
  201.  
  202.         WBool GetShowUpdate() const;
  203.         WBool SetShowUpdate( WBool show );
  204.  
  205.         /***************************************************************
  206.          * Methods
  207.          ***************************************************************/
  208.  
  209.         /***************************************************************
  210.          * Overrides
  211.          ***************************************************************/
  212.  
  213.         virtual WStyle GetDefaultStyle() const;
  214.         virtual WStyle GetDefaultExtendedStyle() const;
  215.         virtual const WChar * InitializeClass();
  216.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  217.                                    void *data );
  218.  
  219.         WBool GetShowState( int ) const;
  220.         WBool SetShowState( int, WBool );
  221.  
  222.         /***************************************************************
  223.          * Event Handlers
  224.          ***************************************************************/
  225.  
  226.     protected:
  227.  
  228.         WBool SizeChangingHandler( WDataNavigator *, WResizeEventData * );
  229.         WBool ResizeHandler( WDataNavigator *, WResizeEventData * );
  230.         WBool EraseBackgroundHandler( WDataNavigator *, WEventData * );
  231.         WBool PaintHandler( WDataNavigator *, WPaintEventData * );
  232.         WBool LeftButtonDownHandler( WDataNavigator * window,
  233.                                      WMouseEventData * event );
  234.         WBool LeftButtonUpHandler( WDataNavigator * window,
  235.                                      WMouseEventData * event );
  236.         WBool MouseMoveHandler( WDataNavigator *, WMouseEventData *event );
  237.  
  238.         WBool DataOpenHandler( WDataNavigator *, WDataOpenEventData *ev );
  239.         WBool DataCloseHandler( WDataNavigator *, WDataCloseEventData *ev );
  240.         WBool DataAvailableHandler( WDataNavigator *, WDataAvailableEventData *ev );
  241.  
  242.         WBool AdjustCursorHandler( WDataNavigator *, WAdjustCursorEventData * );
  243.         WBool DestroyEventHandler( WDataNavigator *, WEventData * );
  244.         WBool ClickEventHandler( WDataNavigator *, WDataNavigatorEventData * );
  245.  
  246.         /***************************************************************
  247.          * Internal
  248.          ***************************************************************/
  249.  
  250.     protected:
  251.  
  252.         struct ButtonInfo {
  253.             WBool    visible;
  254.             WBool    enabled;
  255.             WBool    selected;
  256.             WShort   horizID;
  257.             WShort   vertID;
  258.             WString *tooltip;
  259.         };
  260.  
  261.         WLong WhichButton( const WPoint & pt, WRect *r=NULL );
  262.  
  263.         void DrawButton( ButtonInfo & b, WRect rcItem, WDisplayCanvas *canvas );
  264.         void RedrawButton( WLong which );
  265.         void UpdateButtons( WULong ev );
  266.         void DeleteToolTip();
  267.  
  268.         ButtonInfo   _buttons[ WDNButtonLastPlusOne ];
  269.         WUShort      _numVisible;
  270.         WBitmap      _bitmap;
  271.         WDataTarget *_dataTarget;
  272.         WBool        _keepFocus;
  273.         WBool        _vertical;
  274.         WDNAction    _bofAction;
  275.         WDNAction    _eofAction;
  276.         WBool        _redo;
  277.         WLong        _which;
  278.         WShort       _lastX;
  279.         WShort       _lastY;
  280.         WBool        _showTooltips;
  281. };
  282.  
  283. #ifndef _WNO_PRAGMA_PUSH
  284. #pragma enum pop;
  285. #pragma pack(pop);
  286. #endif
  287.  
  288. #endif // _WDATANAV_HPP_INCLUDED
  289.